package com.example.web.controller;

import com.example.common.Interface.order.entity.dto.*;
import com.example.common.Interface.order.service.OrderService;
import com.example.common.result.Result;
import com.example.common.result.Results;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/order")
@Slf4j
public class OrderController {
    @DubboReference(check = false)
    private OrderService orderService;

    @PostMapping("/placeOrder")
    public Result<PlaceOrderRespDTO> placeOrder(@RequestBody PlaceOrderReqDTO request){
        PlaceOrderRespDTO response = orderService.placeOrder(request);
        return Results.success(response);
    }

    @GetMapping("/listOrder")
    public Result<ListOrderRespDTO> ListOrder(@RequestParam Long userId){
        ListOrderReqDTO request = new ListOrderReqDTO();
        request.setUserId(userId);
        ListOrderRespDTO response = orderService.listOrder(request);
        return Results.success(response);
    }

    @GetMapping("/markOrderPaid")
    public Result<MarkOrderPaidRespDTO> markOrderPaid(@RequestBody MarkOrderPaidReqDTO request){
        MarkOrderPaidRespDTO response = orderService.markOrderPaid(request);
        return Results.success(response);
    }
}
